#include <util\AutomaticInstallation.au3>

Global $InstallProgramPath = "C:\Program Files\BitTorrent\bittorrent.exe"
Global $InstallFolder      = "C:\Program Files\BitTorrent"
	
Global $SetupFile = "BitTorrent-6.4e.exe"
Global $UninstallPath = "C:\Program Files\BitTorrent\uninst.exe"

Main($InstallProgramPath, $InstallFolder, $SetupFile, $UninstallPath)

Func InstallImpl($SetupPath) 
	Dim $Title = ""
	
	RunSetupFile($SetupPath)

	$Title = "BitTorrent Setup"
	WinWaitActive($Title)
	Send("!N")
	Sleep($SleepDelay)
	
	$Text = "Warning"
	WinWaitActive($Title, $Text)
	Send("!N")
	Sleep($SleepDelay)

	$Text = "License Agreement"
	WinWaitActive($Title, $Text)
	Send("!A")
    Sleep($SleepDelay)	

	$Text = "Choose Install Location"
	WinWaitActive($Title, $Text)
	Send("!N")
	Sleep($SleepDelay)

	$Text = "Choose Start Menu Folder"
	
	WinWaitActive($Title, $Text)
	Send("!N")
	Sleep($SleepDelay)
	
	$Text = "&Finish"
	WinWaitActive($Title, $Text)
	Send("{SPACE}")
	Send("{DOWN}")
	Send("{SPACE}")
	Send("!F")
	
	WinWaitClose($Title)

	Return True
EndFunc

Func UninstallImpl($UninstallPath)
	Dim $Title = ""
	Dim $Text = ""
	
	Run($UninstallPath)
	
	$Title = "BitTorrent Uninstall"
	WinWaitActive($title)
	Send("!Y")
	Sleep($SleepDelay)

	$Text = "Remove application data?"
	$retVal = WinWaitActive($Title, $Text, 2)
	If $retVal <> 0 Then
		Send("!Y")
		Sleep($SleepDelay)
	EndIf

	$Text = "BitTorrent was successfully removed from your computer."
	WinWaitActive($Title, $Text)
	Send("{ENTER}")

	Return True
EndFunc




